//#include <cv.h>
//#include <highgui.h>
//#include "abstractProbabilityTransformer.hpp"
//#include "abstractFilter.hpp"
//#include "resourceTracker.h"
//#include "faceDetector.h"
//#include "AbstractHandTracker.hpp"
//#include "HIVideoCapture.hpp"
//#include "handLocaliser.hpp"
//
//#include "AbstractHandTrackerTest.hpp"
//
//#include <iostream>
////TODO clean up includes
//
////this looks up the location of the gtest files in header hiDependenciesForTestFramework.h
////TODO : Design choice? currently I'll keep this dependency in a very specific header file
//// as changing it should cause minimal recompilation.
//
//#include "hiDependenciesForTestFramework.h"
//#include HI_DEPENDENCY_GTEST_HEADER
//
////NOTE: hiDependenciesForTestFramework also sets HI_TEST_VISUALISATION
////which if set will make tests compile to show images of the things they test.
//
////FIXNOW: normalise error according to tracking rect size? (include both normalised and raw error)
//
//using namespace cv;
//		
//void ::AbstractHandTrackerTest::SetUp() {
//	rt = new ResourceTracker( "../config/runtimeSettings/cfg.xml" );
//	rt->loadCategory("TestData");
//	
//	errorThreshold  = 200.0;
//}
//
//void ::AbstractHandTrackerTest::TearDown() {
//	delete rt;
//	delete ht;
//}
//
////void ::AbstractHandTrackerTest::setHandTracker(int trackerCode) {
////	ht = HandTracker::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0))  );
////};
//
//void ::AbstractHandTrackerTest::initTrackerTest(const char* videoNameString) {
//	
//	capPtr = rt->getFileVideoCapture( videoNameString );
//	seqPtr = rt->getPointTags( videoNameString );
//
//	(*capPtr) >> frame;
//	
//	hl = new HandLocaliser();
//	
//	trackingRect = hl->localiseHand( frame );
//	
//	//forcing rectangle to stay inside frame
//	//FIX: this approach is simplistic?
//	//used clipped frame instead?
//	//maybe not, this approach does seem quite easy to use as user
//	if ( trackingRect.x < 0 ) trackingRect.x = 0;
//	if ( frame.cols < trackingRect.x + trackingRect.width ) trackingRect.x = frame.cols - trackingRect.width;
//	if ( trackingRect.y < 0 ) trackingRect.y = 0;
//	if ( frame.rows < trackingRect.y + trackingRect.height ) trackingRect.y = frame.rows - trackingRect.height;
//}
//
//void ::AbstractHandTrackerTest::testTracker(int trackerCode, const char* videoNameString) {
//	
//	RecordProperty( "videoNameString ", videoNameString);
//	initTrackerTest( videoNameString );
//	
//	setHandTracker( trackerCode );
//	
//	namedWindow( "trackingTest", 1 );
//	
//	int tagCount = seqPtr->tagCount;
//	
//	double errorSum = 0; 
//	
//	bool frameErrorBelowThreshold = true;
//	
//	for( int frameCount = 0; frameCount<249; frameCount++) {
//		
//		// -- tracking frame -- //
//		
//		trackingRect = ht->track( frame );
//		
//		Point groundTruth = seqPtr->getNextPointTag();
//		
//		Point trackingRectCentre = Point( trackingRect.x + trackingRect.width/2, trackingRect.y + trackingRect.height/2 );
//		
//		int dX = groundTruth.x - trackingRectCentre.x;
//		int dY = groundTruth.y - trackingRectCentre.y;
//		
//		double frameError = std::sqrt( dX*dX + dY*dY );
//		
//		//Alert if tracking is especially bad
//		if ( frameError > 60 ) {
//			std::cout << "Frame: " << frameCount << ". Position error: " << frameError << std::endl;
//			if (frameError > errorThreshold) {
//				std::cout << "       WARNING: Position error exceeds threshold.";
//				frameErrorBelowThreshold = false;
//			}
//		}
//		errorSum += frameError;
//		
//		// -- Visualisation -- // 
//		{
//			rectangle( frame, Point(trackingRect.x, trackingRect.y),
//					  Point(trackingRect.x + trackingRect.width, trackingRect.y + trackingRect.height),
//					  Scalar::all(250));
//			
//			circle( frame, groundTruth, 1, Scalar(0, 255, 0), 2 ); //radius 1, thickness 2, colour green
//			//FIXNOW: determine rgb vs bgr and update conversions where needed
//			//TEST SHOWS: BGR!
//			
//			circle( frame, trackingRectCentre, 1, Scalar(0, 0, 255), 2 ); //radius 1, thickness 2, colour red
//			//FIXNOW: determine rgb vs bgr and update conversions where needed
//			//TEST SHOWS: BGR!
//			
//			imshow( "trackingTest", frame );
//		}
//		
//		// -- get next frame -- //
//		
//		(*capPtr) >> frame;
//		
//		waitKey(1);
//	}
//	
//	double avgError = errorSum/tagCount;
//	
//	RecordProperty( "Tag count", tagCount );
//	std::cout << "Tag count " << tagCount << std::endl;
//	RecordProperty( "Avg position error ", avgError);
//	std::cout << "Avg position error " << avgError << std::endl;
//	
//	ASSERT_TRUE( frameErrorBelowThreshold );
//	
//}
//
//TEST_F(AbstractHandTrackerTest, LKGREYaaBPMSaaOF0 ) {
//	testTracker( 0, "locVid1c" );
//}

//TEST_F(HandTrackerTest, LKGREYaaBPMSaaOF1 ) {
//	char* videoNameString = "locVid1c";
//	RecordProperty( "videoNameString ", videoNameString);
//	initTrackerTest( videoNameString );
//	
//	ht = HandTracker::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1))  );
//	
//	ASSERT_TRUE( testTracker() );
//}
//
//TEST_F(HandTrackerTest, LKGREYaaBPMSaaOF2 ) {
//	char* videoNameString = "locVid1c";
//	RecordProperty( "videoNameString ", videoNameString);
//	initTrackerTest( videoNameString );
//	
//	ht = HandTracker::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2))  );
//
//	ASSERT_TRUE( testTracker() );
//}
//
//TEST_F(HandTrackerTest, LKGREYaaBPMSaaOF3 ) {
//	char* videoNameString = "locVid1c";
//	RecordProperty( "videoNameString ", videoNameString);
//	initTrackerTest( videoNameString );
//	
//	ht = HandTracker::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3))  );
//	
//	ASSERT_TRUE( testTracker() );
//}
//
//TEST_F(HandTrackerTest, LKGREYaaBPMSaaOF4 ) {
//	char* videoNameString = "locVid1c";
//	RecordProperty( "videoNameString ", videoNameString);
//	initTrackerTest( videoNameString );
//	
//	ht = HandTracker::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(4))  );
//	
//	ASSERT_TRUE( testTracker() );
//}






			
			
		
		
		
